
#include<stdio.h>
void MyPut(int N) {
    for (int row = 1; row <= N; row++) {
        if (row == 1) {
            for (int col = row; col <= N; col++) {
                printf("%d ", col);
            }
        }
        else {
            int count = 0;//0
            int tmp = row - 1;//2
            printf("%d ", row);//3
            count++;
            while (tmp && count <= N) {
                printf("%d ", tmp);
                tmp--;
                count++;
            }
            if (tmp == 0 && count < N) {
                tmp = 2;
                while (count < N) {
                    printf("%d ", tmp);
                    tmp++;
                    count++;
                }
            }
        }      
            printf("\n");
    }
    return;
}
int main() {
    int N[100] = { 0 };
    int sz = 0;

    while (1) {
        scanf("%d", &N[sz]);
        sz++;
        if (!N[sz-1])
            break;
    }
    for (int i = 0; i < sz; i++) {
        MyPut(N[i]);
        if (i < sz - 1)
            printf("\n");
    }
    return 0;
}